package org.wu.reggie.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.wu.reggie.entity.ShoppingCart;

import java.util.List;

public interface ShoppingCartMapper {

    // 根据用户id查看用户下的购物车记录
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> findCartByUserId(Long userId);


    ShoppingCart findUidAndDidOrSid(ShoppingCart shoppingCart);


    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void save(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number = #{number} where id =  #{id}")
    void update(ShoppingCart shoppingCartOne);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);
}
